<template>
  <view v-if="shenheStatus == 0" class="integralDetail">
    <view class="header-tabs">
      <u-tabs
        ref="uTabs"
        :list="tabList"
        :current="current"
        active-color="#FA230A"
        item-width="33.3%"
        @change="tabsChange"
        height="64"
        inactive-color="#262626"
      ></u-tabs>
    </view>
    <view class="detailBox" v-for="(item, index) in detailList" :key="index">
      <view class="detail">
        <view class="type">
          <text>{{ item.content }}</text>
          <text>{{ item.date }}</text>
        </view>
        <view class="count">{{ item.price }}</view>
      </view>
    </view>
    <view style="padding:30rpx 0">
      <u-loadmore  :status="noMore ? 'nomore': 'loadmore'" />
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
export default {
  components:{
        Shenhe,
  },
  data() {
    return {
      current: 0,
      tabList: [
        {
          name: this.$t('person.cashStatus1'),
          status: -1,
        },
        {
          name: this.$t('facePay.income'),
          status: 1,
        },
        {
          name: this.$t('integral.spending'),
          status: 2,
        },
      ],
      page: 1,
      noMore: false,
      detailList: [],
    };
  },
  onLoad() {
    this.getList();
  },
  methods: {
    // 切换导航
    tabsChange(e) {
      this.current = e;
      this.page = this.$options.data().page;
      this.noMore = false;
      this.detailList = [];
      this.getList();
    },
    // 获取详情列表
    async getList(isBottom) {
      // 已经到底
      if(this.noMore) return

      // 触底更新数据
      if(isBottom) {
        this.page++
      }
      try {
        const res = await this.$allrequest.user.recharge_list({
          page: this.page,
          type: this.tabList[this.current].status,
        });
        if (res.code != 0) throw res;
        this.detailList.push(...res.data.list);
        this.noMore = res.data.page_count <= this.page
      } catch (e) {
        //TODO handle the exception
      }
    },
  },
  onReachBottom () {
    this.getList(true);
  },
};
</script>

<style lang="scss" scoped>
.integralDetail {
  width: 100%;
  min-height: 100vh;
  padding-top: 94rpx;
  background-color: #f2f2f2;
}
.header-tabs {
  width: 100%;
  height: 74rpx;
  position: fixed;
  // padding-top: 20rpx;
  top: 0;
  left: 0;
  background-color: #fff;
}
.detailBox {
  width: 100%;
  padding-left: 36rpx;
  background-color: #fff;
  .detail {
    padding: 24rpx 36rpx 24rpx 0;
    border-bottom: 1px solid #f2f2f2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .type {
      width: 500rpx;
      max-width: 500rpx;
      display: flex;
      flex-direction: column;
      font-family: PingFang SC;
      font-size: 28rpx;
      color: #262626;
      text:nth-child(1) {
        width: 100%;
        // white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      text:nth-child(2) {
        font-size: 24rpx;
        color: #8c8c8c;
        margin-top: 4rpx;
      }
    }
    .count {
      font-size: 36rpx;
      color: #262626;
      font-weight: 600;
    }
  }
}
.detailBox:last-child {
  .detail {
    border-bottom: none;
  }
}
</style>
